<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<script type="text/javascript">
	/*	window.onload=function(){
         var oTxt1=document.getElementById('txt1');
         var oTxt2=document.getElementById('txt2');
         var obtn=document.getElementById('btn1');
         obtn.onclick=function(){
         	var re=/<[^<>]+>/g;
         	oTxt2.value=oTxt1.value.replace(re,'');
         }
         }*/
        //search 返回位置,找到返回相应位置,找不到返回-1

         window.onload=function(){
         var oTxt1=document.getElementById('txt1');
        // var oTxt2=document.getElementById('txt2');
         var obtn=document.getElementById('btn1');
         obtn.onclick=function(){
         	var re=/^\w+@[a-z0-9]+\.[a-z]+$/i;
         	//test一部分符合要求,就整个符合要求
         	//^行首   $行尾 如果写在[^a-z]表示除了
         	if(re.test(oTxt1.value)){
         		alert("合法的邮箱");
         	}else{
         		alert("您的邮箱不合法");
         	}
         }
         }
      /*   $.ajax({
         	url: '/path/to/file',  //
         	type: 'default GET (Other values: POST)',//post
         	dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
         	data: {param1: 'value1'},
         })
         .done(function() {
         	console.log("success");
         })
         .fail(function() {
         	console.log("error");
         })
         .always(function() {
         	console.log("complete");
         });*/
         
	</script>
</head>
<body>
	<textarea id="txt1" rows="10" cols="40"></textarea>
	<input id="btn1" type="button" value="转换">
	<textarea id="txt2" rows="10" cols="40"></textarea>
</body>
</html>